package com.dotools.toutiaolibrary.bean;

import android.view.View;
import android.view.ViewGroup;

import com.bykv.vk.openvk.TTNtObject;
import com.bykv.vk.openvk.TTVfObject;

import api.bean.API_TT_FeedBean;

public class TT_FeedBean implements API_TT_FeedBean {
    private TTVfObject mTTFeed;

    public TT_FeedBean(TTVfObject ttFeed) {
        this.mTTFeed = ttFeed;
    }

    @Override
    public String getImageUrl() {
        String imgurl = "";
        if (mTTFeed.getImageList() != null && !mTTFeed.getImageList().isEmpty()) {
            if (mTTFeed.getImageList().get(0) != null && mTTFeed.getImageList().get(0).isValid()) {
                imgurl = this.mTTFeed.getImageList().get(0).getImageUrl();
            }
        }
        return imgurl;
    }

    @Override
    public int getImageMode() {
        return this.mTTFeed.getImageMode();
    }

    @Override
    public String getTitle() {
        return this.mTTFeed.getTitle();
    }

    @Override
    public String getDescription() {
        return this.mTTFeed.getDescription();
    }

    @Override
    public View getVideoView() {
        return this.mTTFeed.getAdView();
    }

    @Override
    public String getSource() {
        return this.mTTFeed.getSource();
    }


    @Override
    public void registerViewForInteraction(ViewGroup var1, View var2, final InteractionListener listener) {
        mTTFeed.registerViewForInteraction(var1, var2, new TTNtObject.AdInteractionListener() {
            @Override
            public void onClicked(View view, TTNtObject ttNtObject) {
                listener.onClicked();
            }

            @Override
            public void onCreativeClick(View view, TTNtObject ttNtObject) {
                listener.onCreativeClick();
            }

            @Override
            public void onShow(TTNtObject ttNtObject) {
                listener.onShow();
            }
        });
    }


    @Override
    public void setVideoListener(final VideoListener listener) {
        this.mTTFeed.setVideoListener(new TTVfObject.VideoVfListener() {

            @Override
            public void onVideoLoad(TTVfObject ttFeedOb) {
                listener.onVideoLoad();
            }

            @Override
            public void onVideoError(int i, int i1) {
                listener.onVideoError(i, i1);
            }

            @Override
            public void onVideoStartPlay(TTVfObject ttVfObject) {
                listener.onVideoStartPlay();
            }

            @Override
            public void onVideoPaused(TTVfObject ttVfObject) {
                listener.onVideoPaused();
            }

            @Override
            public void onVideoContinuePlay(TTVfObject ttVfObject) {
                /**
                 * 视频广告续播
                 */
                listener.onVideoContinuePlay();
            }


            @Override
            public void onProgressUpdate(long l, long l1) {

            }

            @Override
            public void onVideoComplete(TTVfObject ttVfObject) {
                listener.onVideoComplete();
            }

        });
    }
}
